package com.lb.reference;

import java.lang.ref.SoftReference;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2021/4/14 17:24
 * @Description: 软引用应用在缓存上
 */
public class T02_SoftReference {
    public static void main(String[] args) {
        SoftReference<byte[]> m = new SoftReference<>(new byte[1024*1024*10]);
        System.out.println(m.get());
        System.gc();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(m.get());

        byte[] b = new byte[1024*1024*15];
        System.out.println(m.get());
    }
}
